package com.leinao.core.pool;

import com.leinao.domain.PointInfo;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * description
 *
 * @author zhong.wang
 * @date 2025/1/16
 */
public class DevicePointInfoPool {
    private static final DevicePointInfoPool instance = new DevicePointInfoPool();

    private Map<Long, PointInfo> pool ;

    private Map<Long, List<PointInfo>> devicePointList;
    private DevicePointInfoPool(){
        pool = new ConcurrentHashMap<>(1<<100);
        devicePointList = new ConcurrentHashMap<>(1<<100);
    }

    public static DevicePointInfoPool getInstance(){
        return instance;
    }

    public void register(Long id, PointInfo pointInfo){
        pool.putIfAbsent(id,pointInfo);
    }

    public void registerDevicePoint(Long deviceId,List<PointInfo> pointInfos){
        devicePointList.putIfAbsent(deviceId,pointInfos);
    }

    public PointInfo getById(Long id){
        return pool.get(id);
    }

    public List<PointInfo> getByDeviceId(Long deviceId){
        return devicePointList.get(deviceId);
    }
}
